package com.exsun.ex1077.extend

import com.exsun.ex1077.BuildConfig
import com.exsun.ex1077.network.ApiUrl
import com.lzy.okgo.OkGo
import com.lzy.okgo.callback.StringCallback
import com.lzy.okgo.model.Response
import com.zhangping.fastjetpack.extend.getCacheString
import com.zhangping.fastjetpack.extend.removeCache
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import org.json.JSONObject

/**
 * 描述：
 * 作者：ZhangPing
 * 创建时间：2022/5/18 14:45
 */

/**
 * 图片半URL转成完整URL
 */
fun String?.toPhotoUrl(): String{
    if (this.isNullOrEmpty()) return ""
    return (ApiUrl.PHOTO_URL + this)
}

/**
 * 图片完整URL还原成半URL
 */
fun String?.photoUrlToSrcUrl(): String{
    if (this.isNullOrEmpty()) return ""
    return this.replace(ApiUrl.PHOTO_URL, "")
}

/**
 * 注销登录
 */
fun logout(saveInfo: Boolean = false){
    "token".removeCache()
    if (!saveInfo){
        "account".removeCache()
        "password".removeCache()
        "remember".removeCache()
    }
}